package com.eurabia.eggchat.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 功能描述：操作session工具类
 * Created by 张会江
 * on 2018/5/24.
 */
public class SessionUtils {

    /**
     * 设置session
     * @param request
     * @param key
     * @param object
     */
    public static void setSession(HttpServletRequest request, String key, Object object)
    {
        HttpSession session = request.getSession();
        session.setAttribute(key,object);
    }

    /**
     * 获取session
     * @param request
     * @param key
     * @return
     */
    public static Object getSession(HttpServletRequest request, String key)
    {
        HttpSession session = request.getSession();
        Object object = (Object)session.getAttribute(key);
        return object;
    }

    /**
     * 移除session
     * @param request
     * @param key
     */
    public static void removeSession(HttpServletRequest request, String key)
    {
        HttpSession session = request.getSession();
        session.removeAttribute(key);
    }
}
